<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: product_navigator.php 135 2013-09-22 07:30:55Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 135 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:30:55 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$module_smarty = new Smarty();
$module_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');

$path = explode('_', $cPath);
$cat = array_reverse($path);

$products = $db->db_query("SELECT
                                 pc.products_id 
                             FROM ".TABLE_PRODUCTS_TO_CATEGORIES." pc,
                                 ".TABLE_PRODUCTS." p 
							 WHERE 
							 	pc.categories_id = '".$cat[0]."'
                             AND 
                             	p.products_id = pc.products_id  
                             AND 
                             	p.products_status = 1 
                                 ".$product->fsk18().$product->groupCheck(), true);
$i = 0;
while(!$products->EOF) {
	$p_data[$i] = array('pID' => $products->fields['products_id']);
	if($products->fields['products_id'] == $product->data['products_id'])
		$actual_key = $i;
	$i++;
	$products->MoveNext();
}

if ($actual_key == 0) {} 
else {
	$prev_id = $actual_key -1;
	$prev_link = '<a href="'.href_link(FILENAME_PRODUCT_INFO, 'products_id='.$p_data[$prev_id]['pID']).'">'.get_products_name($p_data[$prev_id]['pID']).'</a>';
}

if ($actual_key == (sizeof($p_data) - 1)) {} 
else {
	$next_id = $actual_key +1;
	$next_link = '<a href="'.href_link(FILENAME_PRODUCT_INFO, 'products_id='.$p_data[$next_id]['pID']).'">'.get_products_name($p_data[$next_id]['pID']).'</a>';
}
$module_smarty->assign('PREVIOUS', $prev_link);
$module_smarty->assign('NEXT', $next_link);
$module_smarty->assign('ACTUAL_PRODUCT', $actual_key +1);

$module_smarty->assign('PRODUCTS_COUNT', count($p_data));
$module_smarty->assign('language', $_SESSION['language']);

$module_smarty->caching = false;
$product_navigator = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/product_navigator.html');

$info_smarty->assign('PRODUCT_NAVIGATOR', $product_navigator);